﻿using UnityEngine;
using System.Collections;
using  System.Collections.Generic;
namespace COC.Content.Task{
/// <summary>
/// 模型加载管理器
/// </summary>
public abstract class BaseLoaderManager : MonoBehaviour {

    private static BaseLoaderManager mLoaderManager;
    /// <summary>
    /// 需要处理的模型
    /// </summary>
    protected List<List<BaseLoader>>  queue=new List<List<BaseLoader>>();
    protected Stack<BaseLoader.AbsResultState> state_stack = new Stack<BaseLoader.AbsResultState>();

    /// <summary>
    /// 添加加载器
    /// </summary>
    /// <param name="o"></param>
    public BaseLoaderManager add(BaseLoader o) { return null; }
    /// <summary>
    /// 提交事件激活后，才能执行该加载器
    /// </summary>
    /// <returns></returns>
    public virtual void commit() {
        return;
    }
    protected List<List<BaseLoader>> enqueue(BaseLoader o) { return queue; }
    protected List<List<BaseLoader>> dequeue(int index)
    {
        return queue;
    }
    protected List<List<BaseLoader>> dequeue(int index, BaseLoader o) { return queue; }
    /// <summary>
    /// 队列的长度
    /// </summary>
    /// <returns></returns>
    protected long queueSize()
    {
        return queue.Count;
    }

    
    
	
}
/// <summary>
/// 加载器管理实现
/// </summary>
class LoaderMangerImpl : BaseLoaderManager
{
    //singleton of instance 
    private LoaderMangerImpl instance =new LoaderMangerImpl();

    /// <summary>
    /// get a singleton of LoaderManagerImpl
    /// </summary>
    /// <returns></returns>
    public BaseLoaderManager getSupportLoaderManager()
    { 
     
    if(instance==null){
        instance=new LoaderMangerImpl();
    }
    return instance;
    }

    /// <summary>
    /// 依赖属性，如数据，事件，权限
    /// </summary>
    void enssentialProps() { 

    }
    public override void commit() {
        doExecute(queue);
    }

    private void doExecute(List<List<BaseLoader>> queue)
    {

        try { 
        
        }
        catch (System.Exception)
        {

        }
        finally { 
        }
    }

	}}
